package com.sqx.modules.health.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sqx.modules.health.common.Result;
import com.sqx.modules.health.entity.NcgServiceorderstatus;
import com.sqx.modules.health.service.INcgServiceorderstatusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 预订服务状态 前端控制器
 * </p>
 *
 * @author gxy
 * @since 2022-04-08
 */

@Api(value = "预订服务状态", tags = "预订服务状态", description = "")
@RestController
@RequestMapping("/health/ncgServiceOrderStatus")
public class NcgServiceorderstatusController {
    @Autowired
    private INcgServiceorderstatusService ncgServiceorderstatusService;

    // 新增或更新
    @PostMapping("/save")
    @ApiOperation(value = "新增或更新预订服务状态", notes = "新增或更新预订服务状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "预约服务状态id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "statustime",value = "预约服务信息时间", paramType = "String"),
            @ApiImplicitParam(name = "statusflag",value = "预约服务信息状态(0 预约中 1 预约成功 2 预约失败 默认为0)", paramType = "String"),
    })
    public Result save(NcgServiceorderstatus ncgServiceorderstatus){
        return Result.success(ncgServiceorderstatusService.saveOrUpdate(ncgServiceorderstatus));
    }

    // 根据ID删除
    @GetMapping("/del/{id}")
    @ApiOperation(value = "根据ID删除预订服务状态", notes = "根据ID删除预订服务状态")
    public Result delete(@PathVariable Integer id){
        return Result.success(ncgServiceorderstatusService.removeById(id));
    }

    // 根据IDS删除
    @GetMapping("/del/batch")
    @ApiOperation(value = "根据IDS删除预订服务状态", notes = "根据IDS删除预订服务状态")
    public Result deleteBatch(@RequestBody List<Integer> ids){
        return Result.success(ncgServiceorderstatusService.removeByIds(ids));
    }

    // 查询全部
    @GetMapping("/findAll")
    @ApiOperation(value = "查询全部预订服务状态", notes = "查询全部预订服务状态")
    public Result findAll(){
        return Result.success(ncgServiceorderstatusService.list());
    }

    // 根据ID查询一条记录
    @GetMapping("/findOne")
    @ApiOperation(value = "根据ID查询一条记录预订服务状态", notes = "根据ID查询一条记录预订服务状态")
    public Result findOne(@RequestParam Integer id){
        return Result.success(ncgServiceorderstatusService.getById(id));
    }

    // 分页查询
    @GetMapping("/findPage")
    @ApiOperation(value = "分页查询预订服务状态", notes = "分页查询预订服务状态")
    public Result findPage(@RequestParam Integer pageNum,@RequestParam Integer pageSize){
        QueryWrapper<NcgServiceorderstatus> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("id");
        return  Result.success(ncgServiceorderstatusService.page(new Page<>(pageNum,pageSize),queryWrapper));
    }


}

